//
//  ViewController.m
//  F&B BallScorerEditViewController
//
//  Created by dev1 on 2019/6/11.
//  Copyright © 2019 dev1. All rights reserved.
//

#import "ViewController.h"
#import "EditViewController.h"
@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIButton *basketballBtn;
@property (weak, nonatomic) IBOutlet UIButton *footballBtn;
@property (nonatomic, strong) UIColor *orange;
@property (nonatomic, assign) Ball selectball;
@end

@implementation ViewController
- (void)viewWillAppear:(BOOL)animated {
    [[UIApplication sharedApplication] setIdleTimerDisabled: YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    _orange = [UIColor colorWithRed:232/255.0 green:98/255.0 blue:8/255.0 alpha:1.0];
    _selectball = kNoneBall;
    [self setBorderColor:self.basketballBtn Select:NO];
    [self setBorderColor:self.footballBtn Select:NO];
}

- (void)setBorderColor:(UIButton *)button Select:(BOOL)select {
    button.layer.borderColor = (select?_orange:[UIColor clearColor]).CGColor;
    button.layer.borderWidth = 1;
    button.clipsToBounds = YES;
    button.layer.cornerRadius = 10;
}
- (IBAction)didClickNext:(id)sender {
    if (_selectball == kNoneBall) return;
    UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    EditViewController *vc = [mainStoryBoard instantiateViewControllerWithIdentifier:@"EditViewController"];
    vc.ball = _selectball;
    [self presentViewController:vc animated:YES completion:nil];
}
- (IBAction)didClickBasketball:(id)sender {
    _selectball = kBasketball;
    [self setBorderColor:self.basketballBtn Select:YES];
    [self setBorderColor:self.footballBtn Select:NO];
}
- (IBAction)didClickFootball:(id)sender {
    _selectball = kFootball;
    [self setBorderColor:self.footballBtn Select:YES];
    [self setBorderColor:self.basketballBtn Select:NO];
}

@end
